package com.ah.shanxi_demo.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zt 2020/8/21
 */
public enum SyncEnum implements PolicyCommonInterface{

    //同步类型
    POLICY("policy", "策略同步"),
    ORDER("order", "工单同步"),
    POLICY_ORDER("policy_order", "策略、工单一起同步"),
    SYNC("sync", "策略、工单不需要同步"),
    ;

    private String key;
    private String value;

    final static Map<String, SyncEnum> cacheSync = new HashMap<>(values().length);

    static {
        for (SyncEnum syncEnum : values()) {
            cacheSync.put(syncEnum.key, syncEnum);
        }
    }

    SyncEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public static SyncEnum convert(String key) {
        SyncEnum type = cacheSync.get(key);
        return type;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getValue() {
        return value;
    }

    @Override
    public Integer getKeyInt() {
        return Integer.parseInt(key);
    }
}
